package com.example.myapplication.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

/**
 * 创建者：YangLei
 * 时间：2016/5/30
 * 作用说明：
 * 使用说明：
 */
public class ResultAdapter extends BaseAdapter {
    private Activity activity;
    private List<String> resultLsit;

    public ResultAdapter(Activity activity, List<String> resultLsit) {
        this.activity = activity;
        this.resultLsit = resultLsit;
    }

    @Override
    public int getCount() {
        if (resultLsit == null) {
            return 0;
        }
        return resultLsit.size();
    }

    @Override
    public Object getItem(int position) {
        return resultLsit.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            TextView textView = new TextView(activity);
            textView.setTextColor(activity.getResources().getColor(android.R.color.white));
            textView.setPadding(60, 10, 40, 10);
            textView.setBackgroundColor(activity.getResources().getColor(android.R.color.transparent));
            convertView = textView;
        }
        ((TextView) convertView).setText("第" + (position + 1) + "次测速：\u3000" + resultLsit.get(position));
        return convertView;
    }
}
